package com.ifnk.portaljava.dapWeb.dapweb;

/**
 * <p>Title: 队列类</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2010</p>
 *
 * <p>Company: </p>
 *
 * @author WenSheng.Song.hlyt@gmail.com
 * @version 1.0
 */
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;

/*
 * 用LinkedList实现的队列
 */
public class LinkedListQueue<E> {

	private LinkedList<E> queue = new LinkedList<E>();

	public synchronized boolean add(E e) {
		return queue.add(e);
	}

	public synchronized boolean offer(E e) {
		return queue.offer(e);
	}

	public synchronized E peek() {
		return queue.peek();
	}

	public synchronized E poll() {
		return queue.poll();
	}

	public synchronized E remove() {
		return queue.remove();
	}

	public synchronized boolean addAll(Collection<E> c) {
		return queue.addAll(c);
	}

	public synchronized void clear() {
		queue.clear();
	}

	public synchronized boolean contains(E e) {
		return queue.contains(e);
	}

	public synchronized boolean containsAll(Collection<E> c) {
		return queue.containsAll(c);
	}

	public synchronized boolean isEmpty() {
		return queue.isEmpty();
	}

	public Iterator<E> iterator() {
		return queue.iterator();
	}

	public boolean removeAll(Collection<E> c) {
		return queue.removeAll(c);
	}

	public synchronized int size() {
		return queue.size();
	}

	public synchronized Object[] toArray(int k) {
		Object ob[] = new Object[k];
		int i = 0;
		while (k > 0) {
			ob[i] = poll();
			i++;
			k--;

		}
		return ob;
	}

	public synchronized void subListclear(int k) {
		while (k > 0) {
			poll();
			k--;
		}

	}

}
